<template>
  <div>
    <div class="toggle-button" @click="toggleCollapse()">
      {{text}}</div>
      <hr>
      <div class="toggle-button">欢迎!</div>
    <el-menu
      default-active="1-4-1"
      class="el-menu-vertical-demo"
      @open="handleOpen"
      @close="handleClose"
      :collapse="isCollapse"
      background-color="#262626"
      active-text-color="#0892cd"
      text-color="#fff"
      router
    >
      <el-menu-item index="/main">
        <i class="el-icon-house"></i>
        <span slot="title">首&emsp;&emsp;页</span>
      </el-menu-item>
      <el-menu-item index="/manger">
        <i class="el-icon-user"></i>
        <span slot="title">资产管理</span>
      </el-menu-item>
      <el-menu-item index="/maintenance">
        <i class="el-icon-tickets"></i>
        <span slot="title">客户管理</span>
      </el-menu-item>
      <el-menu-item index="/role">
        <i class="el-icon-news"></i>
        <span slot="title">系统管理</span>
      </el-menu-item>
    </el-menu>
  </div>
</template>

<script>
export default {
  data() {
    return {
         isCollapse: true,
         text:"展开 ",
    };
  },
  created() {
    console.log(this.isCollapse);
  },
  mounted() {},
  methods: {
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
    toggleCollapse(){
      this.isCollapse = !this.isCollapse;
      if(this.isCollapse==true){
        this.text="展开 >";
      }else{
        this.text="收起 <";
      }
    }
  },
};
</script>

<style scoped lang="less">
.toggle-button{
  background-color: #262626;
  font-size: 12px;
  line-height: 50px;
  color: #fff;
  text-align: center;
  cursor: pointer;
}

.el-menu-vertical-demo:not(.el-menu--collapse) {
    width: 200px;
    min-height: 400px;
}
</style>
